from tortoise import fields

from .base import BaseModel, TimestampMixin


# word: string;
# pinyin: string;
# abbr: string;
# explanation: string;
# quote: IQuote;
# source: IQuote;
# example: IQuote;
# usage?: string;
# story?: string[];
# similar?: string[];
# opposite?: string[];

class Idiom(BaseModel, TimestampMixin):
    word = fields.CharField(max_length=200, description="成语", index=True)
    pinyin = fields.CharField(max_length=200, description="拼音")
    abbr = fields.CharField(max_length=200, null=True, default="", description="类型")
    explanation = fields.CharField(max_length=200, null=True, default="", description="释义")
    quote = fields.JSONField(max_length=500, null=True, description="引用")
    source = fields.JSONField(max_length=500, null=True, description="出处")
    example = fields.JSONField(max_length=500, null=True, description="例句")
    usage = fields.CharField(max_length=200, null=True, description="用法")
    story = fields.JSONField(max_length=500, null=True, description="故事")
    similar = fields.JSONField(max_length=500, null=True, description="近义词")
    opposite = fields.JSONField(max_length=500, null=True, description="反义词")


class Meta:
    table = "idiom"
